package com.siren.tank.cor;

import com.siren.tank.GameObject;

public interface Collider {
    boolean collide(GameObject o1, GameObject o2);



    default boolean isIntersection(int rec1X, int rec1Y, int rec1Width, int rec1Height, int rec2X, int rec2Y, int rec2Width, int rec2Height) {

//        return !((this.x+WIDTH) < tank.getX() || this.x > (tank.getX()+BaseTank.WIDTH)) && !((this.y+HEIGHT) < tank.getY() || this.y > (tank.getY() + BaseTank.HEIGHT));
        return xReach(rec1X, rec1Width, rec2X, rec2Width) && yReach(rec1Y, rec1Height, rec2Y, rec2Height);
    }

    default boolean xReach(int rec1X, int rec1Width, int rec2X, int rec2Width) {
        return !((rec2X+rec2Width) < rec1X || rec2X > (rec1X+ rec1Width));
    }

    default boolean yReach(int rec1Y, int rec1Height, int rec2Y, int rec2Height) {
        return !((rec2Y+rec2Height) < rec1Y || rec2Y > (rec1Y+ rec1Height));
    }
}
